<?php
namespace Home\Controller;
use Think\Controller;
class FormController extends Controller{
      public function add(){
        $this->display();
    }

   public function insert(){
    $code = I('post.vcode');
    $verify = new \Think\Verify();
    $ret = $verify->check($code);
    if(!$ret){$this->error('验证码错误');}
    $db = M('Form');
    $data['title'] = I('post.title');
    $data['content'] = I('post.content');
    $data['create_time'] = time();
    $db->add($data);
   }
  
    public function inserterr(){
        $Form   =   D('Form');
        if($Form->create()) {
            $result =   $Form->add();
            if($result) {
                $this->success('数据添加成功！');
            }else{
                $this->error('数据添加错误！');
            }
        }else{
            $this->error($Form->getError());
        }
    }

    public function vcode(){
    $config =    array(
    'fontSize'    =>    30,    // 验证码字体大小
    'length'      =>    4,     // 验证码位数
    'useZh'       =>    true, // 关闭验证码杂点
    'fontttf'     =>    'STXINGKA.TTF',
);
    $Verify =     new \Think\Verify($config);
    $Verify->entry();
}

}